package com.zhengjiang.pattern.demo.singlton;

public class SingleObject2 {

    private SingleObject2(){}

    public volatile static SingleObject2 instance = null;

    public static SingleObject2 getInstance(){
        if (instance==null){
            synchronized (SingleObject2.class){
                if (instance == null) {
                    instance = new SingleObject2();
                }
            }
        }
        return instance;
    }

    public void methodB(){
        System.out.println("SingleObject method B");
    }



}
